package com.common.hbase.domain;

import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;

public class CreateDomain {

    private String tableName;

    private String[] columnFamilys;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String[] getColumnFamilys() {
        return columnFamilys;
    }

    public void setColumnFamilys(String[] columnFamilys) {
        this.columnFamilys = columnFamilys;
    }

    public CreateDomain(String tableName, String... columnFamilys) {
        this.tableName = tableName;
        this.columnFamilys = columnFamilys;
    }

    public HTableDescriptor getHTableDescriptor(){
        HTableDescriptor hTableDescriptor = new HTableDescriptor(TableName.valueOf(tableName));

        if (columnFamilys.length>0){
            for (String columnFamily : columnFamilys) {
                hTableDescriptor.addFamily(new HColumnDescriptor(columnFamily));
            }
        }
        return hTableDescriptor;
    }
}
